<?php 

namespace common\log;

use yii\log\Logger;

class XxyxLogger extends Logger
{
    public static $traceId;
    public static function getTraceId()
    {
        if(empty(self::$traceId)){
            self::$traceId = time().rand(1,10000);
        }

        return self::$traceId;
    }

    public static $traceStep;
    public static function getTraceStep()
    {
        if(empty(self::$traceStep)){
            self::$traceStep = 1;
        }else{
            self::$traceStep += 1;
        }
        return self::$traceStep;
    }

    public static function prefix($message)
    {
        $id = self::getTraceId();
        $step = self::getTraceStep();
        return "[$id][$step]";
    }
}